﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace NewDeMo.ViewModels
{
    public class ExtrPlatViewModel : BindableBase,INavigationAware
    {
        private string _message;
        public ICommand Btn_Jump { get; private set; }
        NavigationParameters p = new NavigationParameters();
        private IRegionManager regionManger;


        public string Message
        {
            get { return _message; }
            set { SetProperty(ref _message, value); }

        }

        public ExtrPlatViewModel(IRegionManager region)
        {
            Message = "我是ExtrPlat页面";
            Btn_Jump = new DelegateCommand<object>(Btn_Jump_Click);
            regionManger = region;
            //Btn_Jump = AddTaskCommand(() => KafkaReport());
        }

        public void Btn_Jump_Click(object obj)
        {
            //Message = "我是ExtrPlat页面,点击了按钮";
            //var p = new NavigationParameters();
            //p.Add("data", 200);
            regionManger.RequestNavigate("ContentRegion", "HomePage");
        }

        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true; // 默认重用当前实例
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            Console.WriteLine("正在离开当前页面...");
            //throw new Exception("正在离开当前页面...");
        }
        /// <summary>
        /// 获取参数
        /// </summary>
        /// <param name="navigationContext"></param>
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            navigationContext.Parameters.GetValue<int>("data");
        }
    }
}